<?php

namespace App\ModelFilters;

use Carbon\Carbon;
use EloquentFilter\ModelFilter;

class UserFilter extends ModelFilter
{
    /**
    * Related Models that have ModelFilters as well as the method on the ModelFilter
    * As [relationMethod => [input_key1, input_key2]].
    *
    * @var array
    */
    public $relations = [];

    public function id($value) {
        return $this->where('id', $value);
    }

    public function status($value) {
        return $this->where('status', $value);
    }

    public function keyword($value): UserFilter
    {
        return $this->where('nickname', 'like', '%'.$value.'%')->orWhere('mobile', 'like', '%'.$value.'%');
    }

    public function at($value) {
        return $this->whereBetween('createtime', [
            $value[0] / 1000,
            $value[1] / 1000,
        ]);
    }
}
